<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>
<style type="text/css">
.mui-bar a{color: #ff9900;}
.mui-btn-primary{background-color: #ff9900;}
.mui-btn-primary:enabled:active{background-color: #ec7230!important;}
.mui-textarea{ height:auto!important; width:100%;}
.area {margin: 20px auto 0px auto;}
.mui-input-group:first-child {margin-top: 20px;}
.mui-rmb i{ font-style:normal; }
.mui-input-row label~input, .mui-input-row label~select, .mui-input-row label~textarea {width: 65%;}
footer .mui-input-row label{line-height:2!important; padding:11px 0; text-align:right; float:right;}
footer .mui-input-row span{line-height:2; padding:11px 10px 11px 0;}
footer .mui-input-row span.mui-rmb{line-height:1.7!important;}
footer .mui-input-row .mui-btn{top: 0; font-size:16px;line-height:1.6!important;border-radius:0; width:35%}
.mui-input-row #get_code{width:auto; border-radius: 0;line-height: 1.7;}
.mui-help-top .mui-table-view-cell{padding: 9px 12px;}
.mui-help-top .mui-icon-help:before{ color:#fe5001; font-size:18px;}
.mui-help-top .mui-small{ font-size:90%!important;}
.mui-help-top .mui-help-info:before{position: absolute;content: ""; height:99%!important;left:0;top:0;width:3px; background-color:#fe5001;}
.mui-input-row.mui-help .mui-help-info{padding-right:30px;}
[data-type=date] .mui-dtpicker-title h5, [data-type=date] .mui-picker{width: 20%!important;}
.mui-dtpicker-title h5,.mui-picker{ display:inline-block!important;}
</style>
<form action="" method="post" onSubmit="return check(this)" style="position: initial">
<footer class="mui-bar mui-bar-footer"<?php  if($activity['aprice']>0) { ?> style="padding:0;"<?php  } ?>>
    <?php  if($activity['aprice']>0) { ?>
    <div class="mui-input-row">
    <button type="submit" class="mui-btn mui-btn-orange">提交报名</button>
    <span class="mui-pull-right mui-text-orange mui-big mui-rmb"><?php echo $afterMarketing['m']?$afterMarketing['pay_price']:$pay_price;?> </span>
    <label>合计：</label>
    </div>
    <?php  } else { ?>
    <button type="submit" class="mui-btn mui-btn-orange mui-btn-block">提交报名</button>
    <?php  } ?>
    <input type="hidden" name="submit" value="提交报名"/>
    <input type="hidden" name="activityid" value="<?php  echo $activityid;?>" />
    <input type="hidden" name="optionid" value="<?php  echo $optionid;?>" />
    <input type="hidden" name="token" value="<?php  echo $_W['token'];?>" />
</footer>
<div class="mui-content">
    <ul class="mui-table-view mui-help-top" style="margin-top:0;">
        <li class="mui-table-view-cell mui-help-info">
            <span class="mui-navigate-left mui-icon-help mui-text-orange mui-small"> &nbsp;&nbsp;&nbsp;&nbsp; 提醒：凡是"必填"，或者"必选"的为必填选项</span>
        </li>
    </ul>
	<div class="mui-content-padded">
        <p>基本信息</p>
    </div>
	<div class="mui-input-group">
        <input type="hidden" name="op" value="join"/>
        <?php  if($sysform['realname']['show']!='0') { ?>
        <div class="mui-input-row">
            <label><?php  echo $sysform['realname']['title'];?></label>
            <input type="text" name="member[realname]" id="realname" placeholder="<?php  echo $sysform['realname']['title'];?> (必填)" value="<?php  echo $profile['realname'];?>">
        </div>
        <?php  } ?>
        <?php  if($sysform['mobile']['show']!='0') { ?>
        <div class="mui-input-row mui-help">
            <label><?php  echo $sysform['mobile']['title'];?></label>
            <input type="number" name="member[mobile]" id="mobile" placeholder="<?php  echo $sysform['mobile']['title'];?> (必填)" pattern="[0-9]*" value="<?php  echo $profile['mobile'];?>"<?php  if(!empty($profile['mobile']) && $_W['_config']['smsswitch']) { ?> onfocus="this.blur()"<?php  } ?>/>
            <?php  if(!empty($profile['mobile']) && $_W['_config']['smsswitch']) { ?>
            <div class="mui-help-info mui-navigate-right mui-text-right js-check-mobile"><span class="mui-badge mui-badge-inverted">点此变更</span></div>
            <?php  } ?>
        </div>
        <?php  } ?>
        <?php  if($_W['_config']['smsswitch']) { ?>
        <div class="mui-input-row mui-help<?php echo $profile['mobile']?'':' active';?>"<?php  if(!empty($profile['mobile'])) { ?> style="display:none"<?php  } ?>>
            <label>验证码</label>
            <input type="number" name="smscode" id="smscode" placeholder="验证码 (必填)" pattern="[0-9]*">
            <div class="mui-help-info mui-text-right" style="padding-right:18px;"><a href="javascript:;" id="get_code">获取验证码</a></div>
        </div>
        <?php  } ?>
        <?php  if(!empty($sysform)) { ?>
            <?php  $sys_form = array_slice($sysform, 2);?>
            <?php  if(is_array($sys_form)) { foreach($sys_form as $k => $v) { ?>
            <?php $placeholder = $v['need'] ? $v['title'] . ' (必填)':$v['title'];?>
                <?php  if($k=='gender' && ($v['show']==='' || $v['show'])) { ?>
                <div class="mui-input-row">
                <label><?php  echo $v['title'];?></label>
                <?php  echo tpl_app_fans_form('gender', $profile['gender'], $placeholder);?>
                </div>
                <?php  } else if($k=='age') { ?>
                <div class="mui-input-row">
                <label><?php  echo $v['title'];?></label>
                <input type="number" name="member[<?php  echo $k;?>]" value="<?php  echo $profile['age'];?>" placeholder="请填写<?php  echo $placeholder;?>" pattern="[0-9]*">
                </div>
                <?php  } else if($k=='birthyear' && ($v['show']==='' || $v['show'])) { ?>
                <div class="mui-input-row">
                <label><?php  echo $v['title'];?></label>
                <?php  echo tpl_app_fans_form('birth', array('year' => $profile['birthyear'], 'month' => $profile['birthmonth'], 'day' => $profile['birthday']), $placeholder);?>
                </div>
                <?php  } else if($k=='idcard') { ?>
                <div class="mui-input-row">
                <label><?php  echo $v['title'];?></label>
                <input type="text" name="member[<?php  echo $k;?>]" value="<?php  echo $profile['idcard'];?>" placeholder="请填写<?php  echo $placeholder;?>">
                </div>
                <?php  } else if($k=='education') { ?>
                <div class="mui-input-row">
                <label><?php  echo $v['title'];?></label>
                <?php  echo tpl_app_fans_form('education',$profile['education'],$placeholder);?>
                </div>
                <?php  } else if($k=='company') { ?>
                <div class="mui-input-row">
                <label><?php  echo $v['title'];?></label>
                <input type="text" name="member[<?php  echo $k;?>]" value="<?php  echo $profile['company'];?>" placeholder="请填写<?php  echo $placeholder;?>">
                </div>
                <?php  } else if($k=='position') { ?>
                <div class="mui-input-row">
                <label><?php  echo $v['title'];?></label>
                <input type="text" name="member[<?php  echo $k;?>]" value="<?php  echo $profile['position'];?>" placeholder="请填写<?php  echo $placeholder;?>">
                </div>
                <?php  } else if($k=='occupation') { ?>
                <div class="mui-input-row">
                <label><?php  echo $v['title'];?></label>
                <input type="text" name="member[<?php  echo $k;?>]" value="<?php  echo $profile['occupation'];?>" placeholder="请填写<?php  echo $placeholder;?>">
                </div>
                <?php  } else if($k=='email') { ?>
                <div class="mui-input-row">
                <label><?php  echo $v['title'];?></label>
                <input type="text" name="member[<?php  echo $k;?>]" value="<?php  echo $profile['email'];?>" placeholder="请填写<?php  echo $placeholder;?>">
                </div>
                <?php  } else if($k=='resideprovince' && ($v['show']==='' || $v['show'])) { ?>
                <div class="mui-input-row">
                <label><?php  echo $v['title'];?></label>
                <?php  echo tpl_app_fans_form('reside', array('province' => $profile['resideprovince'], 'city' => $profile['residecity'], 'district' => $profile['residedist']), $placeholder);?>
                </div>
                <?php  } ?>
            <?php  } } ?>
        <?php  } ?>
        <?php  $key = 0;?>
        <?php  if(is_array($activityForm['0'])) { foreach($activityForm['0'] as $k => $form) { ?>
        <?php  if(!empty($form['fieldstype'])) { ?>
        	<?php  if($form['essential']==1) { ?><input name="essential" type="hidden" value="" title="<?php  echo $form['title'];?>" data-type="<?php  echo $form['fieldstype'];?>"/><?php  } ?>
        	<?php $placeholder = $form['essential']==1 ? $form['title'] . ' (必填)':$form['title'];?>
        	<div class="mui-input-row<?php  if($form['essential']==1) { ?> js-check-fields<?php  } ?>" data-title="<?php  echo $form['title'];?>" data-type="<?php  echo $form['fieldstype'];?>">
            <?php  if($form['fieldstype']=='age') { ?>
            	<label><?php  echo $form['title'];?></label>
                <input type="number" name="member[<?php  echo $form['fieldstype'];?>]" value="<?php  echo $profile['age'];?>" placeholder="请填写<?php  echo $placeholder;?>" pattern="[0-9]*">
            <?php  } else if($form['fieldstype']=='studentid') { ?>
                <label><?php  echo $form['title'];?></label>
                <input type="number" name="member[studentid]" value="<?php  echo $profile['studentid'];?>" placeholder="请填写<?php  echo $placeholder;?>" pattern="[0-9]*">
            <?php  } else if($form['fieldstype']=='zipcode') { ?>
                <label><?php  echo $form['title'];?></label>
                <input type="number" name="member[zipcode]" value="<?php  echo $profile['zipcode'];?>" placeholder="请填写<?php  echo $placeholder;?>" pattern="[0-9]*">
            <?php  } else if($form['fieldstype']=='qq') { ?>
                <label><?php  echo $form['title'];?></label>
                <input type="number" name="member[qq]" value="<?php  echo $profile['qq'];?>" placeholder="请填写<?php  echo $placeholder;?>" pattern="[0-9]*">
            <?php  } else if($form['fieldstype']=='weight') { ?>
            	<?php $placeholder = $form['essential']==1 ? $form['title'] . '：单位kg' . ' (必填)':$form['title'];?>
                <label><?php  echo $form['title'];?></label>
                <input type="number" name="member[weight]" value="<?php  echo $profile['weight'];?>" placeholder="请填写<?php  echo $placeholder;?>" pattern="[0-9]*">
            <?php  } else if($form['fieldstype']=='height') { ?>
            	<?php $placeholder = $form['essential']==1 ? $form['title'] . '：单位cm' . ' (必填)':$form['title'];?>
                <label><?php  echo $form['title'];?></label>
                <input type="number" name="member[height]" value="<?php  echo $profile['height'];?>" placeholder="请填写<?php  echo $placeholder;?>" pattern="[0-9]*">
            <?php  } else if($form['fieldstype']=='gender') { ?>	
                <label><?php  echo $form['title'];?></label>
            	<?php  echo tpl_app_fans_form('gender', $profile['gender'], $placeholder);?>
            <?php  } else if($form['fieldstype']=='birthyear') { ?>
            	<label><?php  echo $form['title'];?></label>
            	<?php  echo tpl_app_fans_form('birth', array('year' => $profile['birthyear'], 'month' => $profile['birthmonth'], 'day' => $profile['birthday']), $placeholder);?>
            <?php  } else if($form['fieldstype']=='resideprovince') { ?>
            	<label><?php  echo $form['title'];?></label>
            	<?php  echo tpl_app_fans_form('reside', array('province' => $profile['resideprovince'], 'city' => $profile['residecity'], 'district' => $profile['residedist']), $placeholder);?>
            <?php  } else if($form['fieldstype']=='education') { ?>
                <label><?php  echo $form['title'];?></label>
                <?php  echo tpl_app_fans_form('education', $profile['education'], $placeholder);?>
            <?php  } else if($form['fieldstype']=='constellation') { ?>
                <label><?php  echo $form['title'];?></label>
                <?php  echo tpl_app_fans_form('constellation', $profile['constellation'], $placeholder);?>
            <?php  } else if($form['fieldstype']=='zodiac') { ?>
                <label><?php  echo $form['title'];?></label>
                <?php  echo tpl_app_fans_form('zodiac', $profile['zodiac'], $placeholder);?>
            <?php  } else if($form['fieldstype']=='bloodtype') { ?>
                <label><?php  echo $form['title'];?></label>
                <?php  echo tpl_app_fans_form('bloodtype', $profile['bloodtype'], $placeholder);?>
            <?php  } else { ?>
                <label><?php  echo $form['title'];?></label>
                <?php  echo tpl_app_fans_form('member['.$form['fieldstype'].']', $profile[$form['fieldstype']], $placeholder);?>
            <?php  } ?>
            </div>
        <?php  } else { ?>
            <input name="form_id[]" type="hidden" class="form-control form_id" value="<?php  echo $form['id'];?>"/>
            <?php  if($form['essential']==1) { ?>
            <input name="essential" type="hidden" value="<?php  echo $key;?>" title="<?php  echo $form['title'];?>" data-type="<?php  echo $form['displaytype'];?>"/>
            <?php  } ?>
            <?php  if($form['displaytype']==0) { ?>
                <h5 class="mui-desc-title mui-pl15">请选择<?php  echo $form['title'];?><?php  if($form['essential']==1) { ?> <span class="mui-text-error">(必选)</span><?php  } ?></h5>
                <?php  if(is_array($form['items'])) { foreach($form['items'] as $formitem) { ?>
                <div class="mui-input-row mui-radio">
                    <label><?php  echo $formitem['title'];?></label>
                    <input name="form_item_val_<?php  echo $key;?>" type="radio" value="<?php  echo $formitem['title'];?>">
                </div>
                <?php  } } ?>
                <p></p>
            <?php  } else if($form['displaytype']==1) { ?>
                <h5 class="mui-desc-title mui-pl15">请选择<?php  echo $form['title'];?>(可多选)<?php  if($form['essential']==1) { ?> <span class="mui-text-error">*</span><?php  } ?></h5>
                <?php  if(is_array($form['items'])) { foreach($form['items'] as $formitem) { ?>
                <div class="mui-input-row mui-checkbox">
                    <label><?php  echo $formitem['title'];?></label>
                    <input name="form_item_val_<?php  echo $key;?>[]" value="<?php  echo $formitem['title'];?>" type="checkbox">
                </div>
                <?php  } } ?>
                <p></p>
            <?php  } else if($form['displaytype']==2) { ?>
                <div class="mui-input-row">
                <label><?php  echo $form['title'];?></label>
                <input class="form_item_val_<?php  echo $k;?>" name="form_item_val_<?php  echo $key;?>" type="text" value="" readonly placeholder="请选择<?php  echo $form['title'];?><?php  if($form['essential']==1) { ?> (必选)<?php  } ?>">
<script type="text/javascript">
$(".form_item_val_<?php  echo $k;?>").on("tap", function(){
	var options = {data: [
	<?php  if(is_array($form['items'])) { foreach($form['items'] as $formitem) { ?>
	{"text":"<?php  echo $formitem['title'];?>","value":"<?php  echo $formitem['title'];?>"},
	<?php  } } ?>
	]};
	var $this = $(this);
	util.poppicker(options, function(items){
		$this.val(items[0].value);
	});
});
</script>
                </div>
            <?php  } else if($form['displaytype']==3) { ?>
                <div class="mui-input-row">
                    <label><?php  echo $form['title'];?></label>
                    <input name="form_item_val_<?php  echo $key;?>" value="" type="text"  placeholder="请输入<?php  echo $form['title'];?><?php  if($form['essential']==1) { ?> (必填)<?php  } ?>">
                </div>
            <?php  } else if($form['displaytype']==4) { ?>
                <div class="mui-input-row">
                    <label><?php  echo $form['title'];?></label>
                    <input name="form_item_val_<?php  echo $key;?>" value="" type="number"  placeholder="请输入<?php  echo $form['title'];?><?php  if($form['essential']==1) { ?> (必填)<?php  } ?>" pattern="[0-9]*">
                </div>
            <?php  } else if($form['displaytype']==5) { ?>
                <p></p>
                <div class="mui-input-cell">
                    <div class="mui-table-view-chevron">
                        <div class="mui-image-uploader">
                            <div class="mui-image-preview js-image-preview<?php  echo $key;?>">
                            	<div class="file-item js-thumb" style="display:none;">
                                <img src="<?php echo FX_URL;?>app/resource/images/nopic.jpg" data-id="" data-preview-src="" data-preview-group="__IMG_UPLOAD_pic"/>
                                <input type="hidden" value="" id="pic<?php  echo $key;?>" name="form_item_val_<?php  echo $key;?>" />
                                </div>
                            </div>
                            <a href="javascript:;" class="mui-upload-btn js-image-pic<?php  echo $key;?> mui-inline"></a>
                        </div>
                        <script>
                            var obj<?php  echo $key;?>=".js-image-pic<?php  echo $key;?>";
                            util.img(obj<?php  echo $key;?>, function(url){
                                $(obj<?php  echo $key;?>).parent().find('.js-image-preview<?php  echo $key;?>').find('#pic<?php  echo $key;?>').val(url.attachment);
                                $(obj<?php  echo $key;?>).parent().find('.js-image-preview<?php  echo $key;?>').find('img').attr("src",url.url);
                                $(obj<?php  echo $key;?>).parent().find('.js-image-preview<?php  echo $key;?>').find('img').attr("data-id",url.id);
                                $(obj<?php  echo $key;?>).parent().find('.js-image-preview<?php  echo $key;?>').find('img').attr("data-preview-src",url.url);
								$(obj<?php  echo $key;?>).parent().find('.js-image-preview<?php  echo $key;?>').find('.js-thumb').show();
                            }, {
                                crop : true,
                                multiple : false,
                                preview : '__IMG_UPLOAD_pic',
								pxSize : 640,
								aspectRatio:1/1
                            });
							setTimeout(function(){
							   $(obj<?php  echo $key;?>).append('<div class="btn-intro" style="position:absolute;color:#d7d7d7;top:54px;line-height: 1.2; left:0; right:0;">上传<?php  echo $form['title'];?><br>(最多1张<?php  if($form['essential']==1 ) { ?>*<?php  } ?>)</div>')
							},1000);
                        </script>
                    </div>
                </div>
                <p></p>
            <?php  } else if($form['displaytype']==6) { ?>
                <p></p>
                <div class="mui-input-cell">
                    <div class="mui-table-view-chevron">
                        <div class="mui-image-uploader">
                            <div class="mui-image-preview js-image-nopic mui-pull-left" style="display:none">
                                <img src="<?php echo FX_URL;?>app/resource/images/nopic.jpg"/>
                            </div>
                            <div class="mui-image-preview js-image-preview<?php  echo $key;?>"></div>
                            <a href="javascript:;" class="mui-upload-btn js-image-pic<?php  echo $key;?> mui-inline"></a>
                        </div>
                        <script>
                            var obj<?php  echo $key;?>=".js-image-pic<?php  echo $key;?>";
                            util.img(obj<?php  echo $key;?>, function(url){
                                $(obj<?php  echo $key;?>).parent().find('.js-image-preview<?php  echo $key;?>').append('<div class="file-item js-thumb"><input type="hidden" value="'+url.attachment+'" name="form_item_val_<?php  echo $key;?>[]" /><img src="'+url.url+'" data-id="'+url.id+'" data-preview-src="" data-preview-group="__IMG_UPLOAD_image" /></div>');
                                $(".js-image-nopic").hide();
                            }, {
                                crop : true,
                                multiple : true,
                                preview : '__IMG_UPLOAD_pic',
								pxSize : 640,
								aspectRatio:1/1
                            });
							setTimeout(function(){
							   $(obj<?php  echo $key;?>).append('<div class="btn-intro" style="position:absolute;color:#d7d7d7;top:54px;line-height: 1.2; left:0; right:0;">上传<?php  echo $form['title'];?><br>(最多8张<?php  if($form['essential']==1 ) { ?>*<?php  } ?>)</div>')
							},1000);
                        </script>
                    </div>
                </div>
                <p></p>
            <?php  } else if($form['displaytype']==7) { ?>
                <div class="mui-input-row js-calendar-<?php  echo $key;?>">
                    <label><?php  echo $form['title'];?></label>
                    <input class="mui-calendar-picker<?php  echo $key;?>" type="text" placeholder="请选择<?php  echo $form['title'];?><?php  if($form['essential']==1) { ?> (必选)<?php  } ?>" value="" readonly>
                    <input type="hidden" value="" name="form_item_val_<?php  echo $key;?>">
                    <script type="text/javascript">
                        $(document).on("tap", ".mui-calendar-picker<?php  echo $key;?>", function(){
                            var $this = $(this);
                            util.datepicker({type: "date", beginYear: 2000, endYear: 2050}, function(rs){
                                $this.val(rs.value + ' ' + rs.h.value + ':' + rs.i.value)
                                .next().val(rs.value + ' ' + rs.h.value + ':' + rs.i.value)
                            });
                        });
                    </script>
                </div>
            <?php  } else if($form['displaytype']==8) { ?>
                <div class="mui-input-row">
                    <label><?php  echo $form['title'];?><?php  if($form['essential']==1) { ?><span class="mui-text-error">*</span><?php  } ?></label>
                    <?php  echo tpl_app_form_field_district('form_item_val_'.$key, array('province' => '','city' => '','district' => ''));?>
                </div>
            <?php  } ?>
            <?php  $key++;?>
        <?php  } ?>
        <?php  } } ?>
        <ul class="mui-table-view">
        <?php  if((!empty($activity['aprice']) && $activity['aprice'] > 0)) { ?>
        	<input type="hidden" name="price" value="<?php echo $afterMarketing['m']?$afterMarketing['pay_price']:$pay_price;?>" class="js-pay-price"/>
            <input type="hidden" name="aprice" value="<?php  echo $activity['aprice'];?>" />
            <li class="mui-table-view-cell mui-pl15"><a href="#">活动费用<span class="mui-pull-right mui-text-orange mui-big mui-rmb"><?php  echo $activity['aprice'];?> <i class="mui-small js-teamquota"> ×<?php echo $activity['team']?$teamnum:1;?></i></span></a></li>
        <?php  } ?>
        <?php  if($activity['team']) { ?>
            <li class="mui-table-view-cell mui-pl15">
            	<span style="line-height:2.5;">输入数量</span>
                <span class="mui-numbox mui-pull-right">
                <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
                <input name="teamnum" class="mui-input-numbox js-pay-team" type="number" value="<?php  echo $teamnum;?>" pattern="[0-9]*">
                <button class="mui-btn mui-btn-numbox-plus" type="button">+</button></span>
             </li>
        <?php  } ?>
        <?php  if($activity['aprice']>0) { ?>
        <?php  if($afterMarketing['m']==1) { ?>
            <li class="mui-table-view-cell mui-pl15">
                <a class="mui-navigate-right js-marketing js-popover" href="#" data-popover='marketing'>活动优惠<span class="mui-badge mui-badge-inverted">满<?php  echo $afterMarketing['max'];?>名：可享 <?php  echo $afterMarketing['p'];?> 折</span></a>
            </li>
        <?php  } else if($afterMarketing['m']==2) { ?>
        	<li class="mui-table-view-cell mui-pl15">
                <a class="mui-navigate-right js-marketing js-popover" href="#" data-popover='marketing'>活动优惠<span class="mui-badge mui-badge-inverted">满<?php  echo $afterMarketing['max'];?>名：立减 <?php  echo $afterMarketing['p'];?> 元</span></a>
            </li>
        <?php  } else if($afterMarketing['m']==3) { ?>
        	<li class="mui-table-view-cell mui-pl15">
                <a class="mui-navigate-right js-marketing js-popover" href="#" data-popover='marketing'>活动优惠<span class="mui-badge mui-badge-inverted">VIP <?php  echo $_W['member']['groupname'];?> 专享：<?php  if($afterMarketing['orderMarket']['vipmarket']==1) { ?><?php  echo $afterMarketing['p'];?> 折<?php  } else { ?>立减 <?php  echo $afterMarketing['p'];?> 元<?php  } ?></span></a>
            </li>
        <?php  } else { ?>
        	<li class="mui-table-view-cell mui-pl15" style="display:none">
                <a class="mui-navigate-right js-marketing js-popover" href="#" data-popover='marketing'>活动优惠<span class="mui-badge mui-badge-inverted"></span></a>
            </li>
        <?php  } ?>
        <?php  } ?>
        <?php  if($_W['_config']['joinmsg']) { ?>
        	<li class="mui-table-view-cell">
                <textarea id="textarea" class="mui-input-clear" name="msg" placeholder="给主办方留言" style="padding:3px;"></textarea>
            </li>
        <?php  } ?>
        </ul>
        <p>&nbsp;</p>
        <?php  if($_W['_config']['agreement']) { ?>
        <div class="mui-content-padded">
            <div class="mui-checkbox mui-agreement">
                <input name="agreement" value="1" type="checkbox"><label class="js-popover">已阅读并同意《<a>用户报名协议</a>》</label>
            </div>
        </div>
        <p>&nbsp;</p>
        <?php  } ?>
    </div>
</div>
</form>
<?php  if($_W['_config']['agreement']) { ?>
<div id="popover" class="mui-popover mui-agreement-info">
	<div class="mui-popover-header">报名协议</div>
	<div class="mui-popover-content">
        <div class="mui-scroll-wrapper">
            <div class="mui-scroll">
            	<div class="mui-content-padded"><?php echo empty($activity['agreement'])?$_W['_config']['joinagreement']:$activity['agreement']?></div>
            </div>
        </div>
    </div>
    <div class="mui-content-padded">
        <button type="button" class="mui-btn mui-btn-success mui-btn-block js-readagreement">已阅读并同意</button>
    </div>
</div>
<?php  } ?>
<?php  if(!empty($marketing)) { ?><?php (!empty($this) && $this instanceof WeModuleSite) ? (include $this->template('activity/popover', TEMPLATE_INCLUDEPATH)) : (include template('activity/popover', TEMPLATE_INCLUDEPATH));?><?php  } ?>
<script type="text/javascript">
mui('.mui-scroll-wrapper').scroll();
$(function(){
	$('input[type=text]').each(function(key){
		if ($(this).attr("readonly")) $(this).attr('onfocus','this.blur()');
	});
	var oldMoble = "<?php  echo $profile['mobile'];?>";
	$('.js-check-mobile').on("tap",function(e) {
		if (!$('#smscode').parent().hasClass('active')){
			$('#smscode').parent().show().addClass('active');
			$('#mobile').removeAttr('onfocus');
			$(this).find('span').text('取消变更');
		}else{
			$('#smscode').parent().hide().removeClass('active');
			$('#mobile').attr('onfocus','this.blur()').val(oldMoble).blur();
			$(this).find('span').text('点此变更');
		}
	});
	//报名协议
	$(".js-popover").on("tap",function(e) {
		mui('#popover').popover('toggle');
	});	
	$(".js-readagreement").on("tap",function(e) {
		$("input[name='agreement']").prop("checked", true);
		mui('#popover').popover('toggle');
	});
	//报名人数控制
	var payprice, aprice =<?php  echo $activity['aprice'];?>,teamquota=parseInt(<?php  echo $activity['teamquota'];?>),quota=parseInt(<?php  echo $quota;?>),joinnum=parseInt(<?php  echo $joinnum;?>);
	var forquota = quota?quota-joinnum:0;
	$("input.js-pay-team").bind('input propertychange, change', function(e) {
		e.stopPropagation();
		$this = $(this);
		if ($(this).val()==0){
			$(this).val(1);
		}
		//判断名额
		if($(this).val() > forquota && quota > 0){
			$(this).val(forquota);
			util.alert('已超出剩余数量范围', ' ', function() {
				$(".js-pay-team").val(forquota);
			});
		}
		//团名额限制
		if ($(this).val() > teamquota && teamquota > 0){
			$(".js-pay-team").val(teamquota);
			util.alert('已达该票输入最大值', ' ', function() {
				$('.js-pay-price').val(payprice);
			});
		}
		//配制优惠
		if(aprice>0){
			var maxmeet=0,give=0,markettype=<?php  echo $afterMarketing['m'];?>,vipmarket=parseInt("<?php  echo $afterMarketing['orderMarket']['vipmarket'];?>"),obj_ = new Object();
			if (vipmarket){
				maxmeet=<?php  echo $afterMarketing['max'];?>,give=<?php  echo $afterMarketing['p'];?>;
			}else{
				var falsemax=0;
				$("#marketing .js-marketlist").each(function(key){
					$(this).find('input').attr('disabled',"true");
					$(this).find('input').removeAttr("checked");
					$(this).addClass('mui-disabled');
					if ($this.val() >= $(this).data("meet")){
						if ($(this).data("meet") > maxmeet) obj_ = this;
						give = $(this).data("meet")>maxmeet?$(this).find("input[name='give']").val():give;
						maxmeet = $(this).data("meet")>maxmeet?$(this).data("meet"):maxmeet;
						markettype = $(this).data("type");
					}else{
						falsemax++;
					}
				});
				if (falsemax==$("#marketing .js-marketlist").length) markettype=0,maxmeet=0;
				$(obj_).find('input').prop("checked",'true');
				$(obj_).removeClass('mui-disabled');
			}
			switch(markettype){
				case 0: payprice = (aprice*$(this).val()).toFixed(2);
						$('.js-marketing').parent().hide();
						break;
				case 1: $('.js-marketing').find('span').html('满'+maxmeet+'名：可享 '+give+' 折');
						$('.js-marketing').parent().show();
						payprice = (aprice*$(this).val()*give*0.1).toFixed(2);
						//console.log(payprice);
						break;
				case 2: $('.js-marketing').find('span').html('满'+maxmeet+'名：立减 '+give+' 元');
						$('.js-marketing').parent().show();
						payprice = (aprice*$(this).val()-give).toFixed(2);
						//console.log(payprice);
				case 3: 
					if (vipmarket==1){
						$('.js-marketing').find('span').html("VIP <?php  echo $_W['member']['groupname'];?> 专享："+give+' 折');
						payprice = (aprice*$(this).val()*give*0.1).toFixed(2);
					}else{
						$('.js-marketing').find('span').html("VIP <?php  echo $_W['member']['groupname'];?> 立减："+give+' 元');
						payprice = (aprice*$(this).val()-give).toFixed(2);
					}
						//console.log(payprice);
					break;
				default:break;
			}
			$('.js-pay-price').val(payprice);
			$('.js-teamquota').text(" ×" + $(this).val());
			$('footer .mui-rmb').html(payprice);
		}
	});

	<?php  if($_W['_config']['smsswitch']) { ?>
	var issend=true;//短信初始控制开关
	if($.getCookie("captcha")){  
		var count = $.getCookie("captcha");  
		var btn = $('#get_code');  
		btn.html(count+"秒后可重发");
		issend=false;
		var resend = setInterval(function(){  
			count--;  
			if (count > 0){  
				btn.html(count+"秒后可重发");
				$.setCookie("captcha", count);
			}else {  
				clearInterval(resend);  
				btn.html("获取验证码");
				issend=true;
				$.delCookie("captcha");
			}  
		}, 1000);  
	}
	$("#get_code").on("tap",function() {
		if(issend){ 
			//验证电话号码手机号码 
			var phoneObj = document.getElementById('mobile');
			if (phoneObj.value != ""){  
				var phoneVal=phoneObj.value;  
				var p1 = /^(0|86|17951)?(13[0-9]|15[012356789]|17[0-9]|18[0-9]|14[57])[0-9]{8}$/;  
				var me = false;  
				if (p1.test(phoneVal)) me=true;  
				if (!me){  
					phoneObj.value='';
					util.alert('请输入正确的手机号码', ' ', function() {
						phoneObj.focus(); 
					}); 
					return false;  
				}else{ 
					issend=false; 
					var btn = $(this);  
					var count = 60;  
					var resend = setInterval(function(){  
						count--;  
						if (count > 0){  
							btn.html(count+"秒后可重发");  
							$.setCookie("captcha", count);
						}else {  
							clearInterval(resend);  
							issend=true;
							btn.html("获取验证码");
							$.delCookie("captcha");
						}  
					}, 1000);
					$.ajax({
						type: 'POST',
						url: "<?php  echo app_url('api/sendsms/code')?>&mobile="+phoneVal,
						dataType: 'json',
						success: function(data){
							console.log(data);
							if(data.hasOwnProperty("result") || data.Code=='OK'){
								util.toast('发送成功');
							}else{
								var err_msg = data.hasOwnProperty("Message") ? data.Message : data.sub_msg;
								util.alert(err_msg, ' ', function() {return false;});
							}
						},
						error:function(){
							util.alert('服务器错误, 请联系官方人员', ' ', function() {return false;});
						}
					});
				} 
			}else{ 
				util.toast('手机不能为空',"","error");
				return false; 
			} 
		} 
	});
	<?php  } ?>
});
function check(form) {
	var patt = new RegExp(/\s+/g);
	var checksubmit = false,value='';
<?php  if($sysform['realname']['show']!='0') { ?>
	if ($.trim(form['member[realname]'].value) == '') {
		util.alert('请输入姓名', ' ', function() {
			$(form['member[realname]']).focus();
		});
		return false;
	}
<?php  } ?>
<?php  if($sysform['mobile']['show']!='0') { ?>
	if (!form['member[mobile]'].value) {
		util.alert('请输入手机号', ' ', function() {
			$(form['member[mobile]']).focus();
		});
		return false;
	}else{
		 var mobile = $('#mobile').val();
		 var pattern = /^1[34578]\d{9}$/; 
		  
		 if (!pattern.test(mobile)) {
				 util.alert('手机号不合法', ' ', function() {
					$(form['member[mobile]']).focus();
				 });
				return false;
		 }
	}
<?php  } ?>
<?php  if(!empty($sysform)) { ?>
	<?php  if(is_array($sys_form)) { foreach($sys_form as $k => $v) { ?>
		<?php  if($k=='gender' && ($v['show']=='' || $v['show']) && $v['need']) { ?>
		if (!form['<?php  echo $k;?>'].value) {
			util.alert("请选择<?php  echo $v['title'];?>", ' ', function() {
				$(".mui-gender-picker").trigger('tap');
			});
			return false;
		}
		<?php  } else if($k=='age' && $v['need']) { ?>
		if (!form['member[<?php  echo $k;?>]'].value) {
			util.alert("请输入<?php  echo $v['title'];?>", ' ', function() {
				$(form['member[<?php  echo $k;?>]']).trigger('tap');
			});
			return false;
		}
		<?php  } else if($k=='birthyear' && ($v['show']=='' || $v['show']) && $v['need']) { ?>
		if (form['birth[year]'].value=='0') {
			util.alert("选择<?php  echo $v['title'];?>", ' ', function() {
				$("input[name='birth']").trigger('tap');
			});
			return false;
		}
		<?php  } else if($k=='idcard' && $v['need']) { ?>
		var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
		if (!pattern.test($(form['member[<?php  echo $k;?>]']).val())){
			util.alert("<?php  echo $v['title'];?>不合法", ' ', function() {
				$(form['member[<?php  echo $k;?>]']).focus();
			});
			checksubmit = false;
			return false;
		}
		<?php  } else if($k=='education' && $v['need']) { ?>
		if (!form['<?php  echo $k;?>'].value) {
			util.alert("请选择<?php  echo $v['title'];?>", ' ', function() {
				$(".mui-education-picker").trigger('tap');
			});
			return false;
		}
		<?php  } else if($k=='company' && $v['need']) { ?>
		if (!form['member[<?php  echo $k;?>]'].value) {
			util.alert("请输入<?php  echo $v['title'];?>", ' ', function() {
				$(form['member[<?php  echo $k;?>]']).trigger('tap');
			});
			return false;
		}
		<?php  } else if($k=='position' && $v['need']) { ?>
		if (!form['member[<?php  echo $k;?>]'].value) {
			util.alert("请输入<?php  echo $v['title'];?>", ' ', function() {
				$(form['member[<?php  echo $k;?>]']).trigger('tap');
			});
			return false;
		}
		<?php  } else if($k=='occupation' && $v['need']) { ?>
		if (!form['member[<?php  echo $k;?>]'].value) {
			util.alert("请输入<?php  echo $v['title'];?>", ' ', function() {
				$(form['member[<?php  echo $k;?>]']).trigger('tap');
			});
			return false;
		}
		<?php  } else if($k=='email' && $v['need']) { ?>
		if (!form['member[<?php  echo $k;?>]'].value) {
			util.alert("请输入<?php  echo $v['title'];?>", ' ', function() {
				$(form['member[<?php  echo $k;?>]']).trigger('tap');
			});
			return false;
		}
		<?php  } else if($k=='resideprovince' && ($v['show']=='' || $v['show']) && $v['need']) { ?>
		if (!form['reside[province]'].value) {
			util.alert("请选择<?php  echo $v['title'];?>", ' ', function() {
				$(".mui-district-picker-reside").trigger('tap');
			});
			return false;
		}
		<?php  } ?>
	<?php  } } ?>
<?php  } ?>

<?php  if($_W['_config']['smsswitch']) { ?>
	var check_tel = $('#smscode').parent().data('check');
	if (check_tel){
		if (!form['smscode'].value) {
			util.alert('请输入验证码', ' ', function() {
				$("input[name='smscode']").focus();
			});
			return false;
		}else{
			var smscode = $('#smscode').val();		  
			if ($.getCookie("sms_code")!=smscode) {
				util.alert('验证码不正确', ' ', function() {
					$("input[name='smscode']").focus();
				});
				return false;
			}else if(form['member[mobile]'].value!=$.getCookie("sms_mobile")){
				util.alert('当前手机号与验证码不符', ' ', function() {
					$(form['member[mobile]']).focus();
				});
				return false;
			}
		}
	}
<?php  } ?>

	if($(form['essential']).length){
		$(form['essential']).each(function(){
			var inputkey = $(this).val();
			var formtype = $(this).data('type');
			var inputName = 'form_item_val_'+$(this).val();
			if (inputkey!=''){
				if ($(form[inputName+'[]']).length || formtype=='6'){
					inputName = inputName+'[]';
					if ($(form[inputName]).attr("type")=='checkbox' && $('input:checkbox[name="'+inputName+'"]:checked').length == 0) {
						util.alert($(this).attr("title")+'为必选项', ' ', function() {
							$(form[inputName]).focus();
						});
						checksubmit = false;
						return false;
					}else if(formtype=='6' && !$(form[inputName]).length){
						util.alert($(this).attr("title")+'不能为空', ' ', function() {});
						checksubmit = false;
						return false;
					}
				}else if($(form[inputName+'[province]']).length){
					if (!form[inputName+'[province]'].value) {
						util.alert($(this).attr("title")+'为必选项', ' ', function() {
							$('.mui-district-picker-'+inputName).trigger('tap');
						});
						checksubmit = false;
						return false;
					}
				}else{
					if ($.trim(form[inputName].value)=="" && $(form[inputName]).attr("type")!='radio' && !$(form[inputName]).next().val()) {
						var msg = $(form[inputName]).siblings('.mui-calendar-picker'+inputkey).length?'为必选项':'不能为空';
						util.alert($(this).attr("title")+msg, ' ', function() {
							if (formtype=='3' || formtype=='4'){
								$(form[inputName]).focus();
							}
							$(form[inputName]).siblings('.mui-calendar-picker'+inputkey).trigger('tap')
							$(form[inputName]).trigger('tap');
						});
						checksubmit = false;
						return false;
					}else if($(form[inputName]).attr("type")=='radio' && $('input:radio[name="'+inputName+'"]:checked').length == 0){
						util.alert($(this).attr("title")+'为必选项', ' ', function() {
							$(form[inputName]).focus();
							$(form[inputName]).trigger('tap');
						});
						checksubmit = false;
						return false;
					}
				}
			}else{
				inputName = "member["+formtype+"]";
				var typeStr = "education,birthyear,resideprovince,constellation,zodiac,bloodtype";
				if (typeStr.indexOf(formtype)>-1){
						if (formtype=='birthyear' && $(form['birth']).val()==""){
							util.alert($(this).attr("title")+'为必选项', ' ', function() {
								$(form['birth']).trigger('tap');
							});
							checksubmit = false;
							return false;
						}else if(formtype=='resideprovince' && $('.mui-district-picker-reside').val()==""){
							util.alert($(this).attr("title")+'为必选项', ' ', function() {
								$('.mui-district-picker-reside').trigger('tap');
							});
							checksubmit = false;
							return false;
						}else if ($(form[formtype]).val()==""){
							util.alert($(this).attr("title")+'为必选项', ' ', function() {
								$(form[formtype]).siblings('.mui-'+formtype+'-picker').trigger('tap');
							});
							checksubmit = false;
							return false;
						}					
				}else if($.trim($(form[inputName]).val())=="" && $(form[inputName]).length){
					util.alert($(this).attr("title")+'不能为空', ' ', function() {
						$(form[inputName]).focus();
					});
					checksubmit = false;
					return false;
				}else{
					var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
					if (formtype == 'idcard' && !pattern.test($(form[inputName]).val())){
						util.alert($(this).attr("title")+'不合法', ' ', function() {
							$(form[inputName]).focus();
						});
						checksubmit = false;
						return false;
					}
				}
			}
			checksubmit = true;
		});
	}else{
		checksubmit = true;
	}
	//if (form['gender'].value=='') {
	//	util.alert('请选择您的性别', ' ', function() {
	//		$(".js-user-options").trigger('tap');
	//	});
	//	return false;
	//}
	if (checksubmit){
		<?php  if($_W['_config']['agreement']) { ?>
		if ($('input:checkbox[name="agreement"]:checked').length == 0) {
			util.alert('请阅读并同意报名协议', ' ', function() {
				$("input[name='agreement']").focus();
			});
			return false;
		}
		<?php  } ?>
		util.loading();
		$.ajax({
			type: 'POST',
			url: "<?php  echo app_url('home/join/validquota',array('activityid'=>$activityid,'optionid'=>$optionid))?>&teamnum="+form['teamnum'].value,
			dataType: 'json',
			async:false, 
			success: function(data){
				setTimeout(function() {
					util.loading().close();
				},500);
				if(!data.errno){
					checksubmit = true;
				}else{
					checksubmit=false;
					setTimeout(function() {
						util.alert(data.message, ' ', function() {return false;});
					},450);
				}
			},
			error:function(){
				setTimeout(function() {
					util.loading().close();
				},500);
				checksubmit=false;
				setTimeout(function() {
					util.alert('服务器加载错误, 请联系主办方', ' ', function() {return false;});
				},450);
			}
		});
	}
	return checksubmit;
}
</script>
<script>;</script><script type="text/javascript" src="http://ke.iswoole.com/app/index.php?i=3&c=utility&a=visit&do=showjs&m=fx_activity"></script></body>
</html>